package com.shaw.mybatisx.plugin;


import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 此类主要用于向责任链中的下一个plugin传递执行
 * Created by asus on 2018/4/10.
 */
public class Invocation {
    private Object target;
    private Method method;
    private Object[] args;

    public Invocation(Object target,Method method,Object[] args){
        this.target = target;
        this.method = method;
        this.args = args;
    }

    public Object getTarget() {
        return target;
    }

    public Method getMethod() {
        return method;
    }

    public Object[] getArgs() {
        return args;
    }

    public Object proceed(){
        try {
            return method.invoke(target, args);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }
        return null;
    }
}
